package com.example.demo.entity.vo;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

@Data
public class LoginerVO {
    private String token;
    private String userId;
    private String name;
    private String roleName;
    private String roleCode;
    private long time;

    public void setLoginer(JSONObject js) {
        this.token = js.getString("token");
        this.userId = js.getString("userId");
        this.name = js.getString("name");
        this.roleName = js.getString("roleName");
        this.roleCode = js.getString("roleCode");
        this.time = Long.parseLong(js.getString("time"));
    }

    public void expire() {
        this.time = System.currentTimeMillis();
    }

    /*public String toJSONString() {
        JSONObject js = new JSONObject();
        js.put("token", token);
        js.put("name", name);
        js.put("roleName", roleName);
        js.put("roleCode", roleCode);
        js.put("time", String.valueOf(time));
        return js.toJSONString();
    }*/
}
